<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>pvstanal</title>
    <link rel="stylesheet" type="text/css" href="csound.css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.78.1" />
    <link rel="home" href="index.html" title="The Canonical Csound Reference Manual" />
    <link rel="up" href="OpcodesTop.html" title="Orchestra Opcodes and Operators" />
    <link rel="prev" href="pvspitch.html" title="pvspitch" />
    <link rel="next" href="pvstencil.html" title="pvstencil" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">pvstanal</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="pvspitch.html">Prev</a> </td>
          <th width="60%" align="center">Orchestra Opcodes and Operators</th>
          <td width="20%" align="right"> <a accesskey="n" href="pvstencil.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry">
      <a id="pvstanal"></a>
      <div class="titlepage"></div>
      <a id="IndexPvstanal" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">pvstanal</span>
        </h2>
        <p>pvstanal — 
Phase vocoder analysis processing with onset detection/processing.
          </p>
      </div>
      <div class="refsect1">
        <a id="idp139800528"></a>
        <h2>Description</h2>
        <p>
<span class="emphasis"><em>pvstanal</em></span> implements phase vocoder analysis by reading function tables
containing sampled-sound sources, with <a class="link" href="GEN01.html" title="GEN01"><em class="citetitle">GEN01</em></a>, and
<span class="emphasis"><em>pvstanal</em></span> will accept deferred allocation tables.
  </p>
        <p>
This opcode allows for time and frequency-independent scaling. Time is advanced internally, but controlled by a tempo scaling parameter; when an onset is detected, timescaling is momentarily stopped to avoid smearing of attacks. The quality of the effect is generally improved with phase locking switched on. 
  </p>
        <p>
<span class="emphasis"><em>pvstanal</em></span> will also scale pitch, independently of frequency, using a transposition factor (k-rate).
  </p>
      </div>
      <div class="refsect1">
        <a id="idp139805888"></a>
        <h2>Syntax</h2>
        <pre class="synopsis">fsig <span class="command"><strong>pvstanal</strong></span> ktimescal, kamp, kpitch, ktab, [kdetect, kwrap, ioffset,ifftsize, ihop, idbthresh]
      </pre>
      </div>
      <div class="refsect1">
        <a id="idp139808288"></a>
        <h2>Initialization</h2>
        <p>
      <span class="emphasis"><em>ifftsize</em></span> -- FFT size (power-of-two), defaults to 2048.
    </p>
        <p>
      <span class="emphasis"><em>ihop</em></span> -- hopsize, defaults to 512
    </p>
        <p>
      <span class="emphasis"><em>ioffset</em></span> -- startup read offset into table, in secs.
    </p>
        <p>
      <span class="emphasis"><em>idbthresh</em></span> -- threshold for onset detection, based on dB power spectrum ratio between two successive windows. A detected ratio above it will cancel timescaling momentarily, to avoid smearing (defaults to 1).
      By default anything more than a 1 dB inter-frame power difference will be detected as an onset.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp139813296"></a>
        <h2>Performance</h2>
        <p>
      <span class="emphasis"><em>ktimescal</em></span> -- timescaling ratio, &lt; 1 stretch, &gt; 1 contract.
    </p>
        <p>
      <span class="emphasis"><em>kamp</em></span> -- amplitude scaling
    </p>
        <p>
      <span class="emphasis"><em>kpitch</em></span> -- grain pitch scaling (1=normal pitch, &lt; 1 lower, &gt; 1 higher; negative, backwards)
    </p>
        <p>
      <span class="emphasis"><em>kdetect</em></span> -- 0 or 1, to switch onset detection/processing. The onset detector checks for power difference between analysis windows. If more than what has been specified in the dbthresh parameter, an onset is declared.
It suspends timescaling momentarily so the onsets are not modified.
    </p>
        <p>
      <span class="emphasis"><em>ktab</em></span> -- source signal function table. Deferred-allocation tables (see
      <a class="link" href="GEN01.html" title="GEN01"><em class="citetitle">GEN01</em></a>) are accepted, but the opcode
      expects a mono source. Tables can be switched at k-rate.
    </p>
        <p>
      <span class="emphasis"><em>kwrap</em></span> -- 0 or 1, to switch on/off table wrap-around read (default to 1)
    </p>
      </div>
      <div class="refsect1">
        <a id="idp139821376"></a>
        <h2>Examples</h2>
        <p>
      Here is an example of the pvstanal opcode. It uses the file <a class="ulink" href="examples/pvstanal.csd" target="_top"><em class="citetitle">pvstanal.csd</em></a>.
      </p>
        <div class="example">
          <a id="idp139823152"></a>
          <p class="title">
            <strong>Example 711. Example of the pvstanal opcode.</strong>
          </p>
          <div class="example-contents">
            <p>See the sections <a class="link" href="UsingRealTime.html" title="Real-Time Audio"><em class="citetitle">Real-time Audio</em></a> and <a class="link" href="CommandFlags.html" title="Csound command line"><em class="citetitle">Command Line Flags</em></a> for more information on using command line flags.</p>
            <pre class="programlisting">
<span class="csdtag">&lt;CsoundSynthesizer&gt;</span>
<span class="csdtag">&lt;CsOptions&gt;</span>
<span class="comment">; Select audio/midi flags here according to platform</span>
-odac      <span class="comment">;;;realtime audio out</span>
<span class="comment">;-iadc    ;;;uncomment -iadc if realtime audio input is needed too</span>
<span class="comment">; For Non-realtime ouput leave only the line below:</span>
<span class="comment">; -o pvstanal.wav -W ;;; for file output any platform</span>
<span class="csdtag">&lt;/CsOptions&gt;</span>
<span class="csdtag">&lt;CsInstruments&gt;</span>

<span class="ohdr">sr</span> <span class="op">=</span> 44100
<span class="ohdr">ksmps</span> <span class="op">=</span> 32
<span class="ohdr">nchnls</span> <span class="op">=</span> 2
<span class="ohdr">0dbfs</span>  <span class="op">=</span> 1

gifil     <span class="ohdr">ftgen</span>     0, 0, 0, 1, "fox.wav", 0, 0, 1

<span class="oblock">instr</span> 1

fsig      <span class="opc">pvstanal</span>  p4, 1, p5, gifil, p6, p7
aout      <span class="opc">pvsynth</span>   fsig
          <span class="opc">outs</span>      aout, aout
<span class="oblock">endin</span>

<span class="oblock">instr</span> 2

kspeed    <span class="opc">randi</span>     2, 2, 2 <span class="comment">;speed randomly between -2 and 2</span>
kpitch    <span class="opc">randi</span>     2, 2, 2 <span class="comment">;pitch between 2 octaves lower or higher</span>
fsig      <span class="opc">pvstanal</span>  kspeed, 1, <span class="opc">octave</span>(kpitch), gifil
aout      <span class="opc">pvsynth</span>   fsig
          <span class="opc">outs</span>      aout, aout
<span class="oblock">endin</span>

<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>
<span class="comment">;           speed pch det wrap</span>
<span class="stamnt">i</span> 1 0 2.757 1     1   0   0
<span class="stamnt">i</span> 1 3 .     2     1   0   0
<span class="stamnt">i</span> 1 6 .     2     1   0   1
<span class="stamnt">i</span> 1 9 .     1     .75
<span class="stamnt">i</span> 2 12 10 <span class="comment">;random scratching</span>
<span class="stamnt">e</span>
<span class="csdtag">&lt;/CsScore&gt;</span>
<span class="csdtag">&lt;/CsoundSynthesizer&gt;</span>
</pre>
          </div>
        </div>
        <p><br class="example-break" />
    </p>
      </div>
      <div class="refsect1">
        <a id="idp139827440"></a>
        <h2>Credits</h2>
        <p>
      </p>
        <table border="0" summary="Simple list" class="simplelist">
          <tr>
            <td>Author: Victor Lazzarini</td>
          </tr>
          <tr>
            <td>February 2010</td>
          </tr>
        </table>
        <p>
    </p>
        <p>New plugin in version 5.13</p>
        <p>February 2005.</p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="pvspitch.html">Prev</a> </td>
          <td width="20%" align="center">
            <a accesskey="u" href="OpcodesTop.html">Up</a>
          </td>
          <td width="40%" align="right"> <a accesskey="n" href="pvstencil.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">pvspitch </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> pvstencil</td>
        </tr>
      </table>
    </div>
  </body>
</html>
